var RedditPixel_RS=function(t){"use strict";const e={LOG:{value:0,method:console.log},INFO:{value:1,method:console.info},DEBUG:{value:2,method:console.debug},WARN:{value:3,method:console.warn},ERROR:{value:4,method:console.error}};function n(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function r(t){return function e(r){return 0===arguments.length||n(r)?e:t.apply(this,arguments)}}function o(t){return function e(o,i){switch(arguments.length){case 0:return e;case 1:return n(o)?e:r((function(e){return t(o,e)}));default:return n(o)&&n(i)?e:n(o)?r((function(e){return t(e,i)})):n(i)?r((function(e){return t(o,e)})):t(o,i)}}}const i=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function a(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function s(t,e,n){for(var r=0,o=n.length;r=0;)c(e=p[n],t)&&!y(r,e)&&(r[r.length]=e),n-=1;return r})):r((function(t){return Object(t)!==t?[]:Object.keys(t)})),v=r((function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)}));function w(t,e,n,r){var o=a(t);function i(t,e){return m(t,e,n.slice(),r.slice())}return!s((function(t,e){return!s(i,e,t)}),a(e),o)}function m(t,e,n,r){if(u(t,e))return!0;var o,i,a=v(t);if(a!==v(e))return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof e["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e)&&"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof e.equals)return"function"==typeof t.equals&&t.equals(e)&&"function"==typeof e.equals&&e.equals(t);switch(a){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===(o=t.constructor,null==(i=String(o).match(/^function (\w*)/))?"":i[1]))return t===e;break;case"Boolean":case"Number":case"String":if(typeof t!=typeof e||!u(t.valueOf(),e.valueOf()))return!1;break;case"Date":if(!u(t.valueOf(),e.valueOf()))return!1;break;case"Error":return t.name===e.name&&t.message===e.message;case"RegExp":if(t.source!==e.source||t.global!==e.global||t.ignoreCase!==e.ignoreCase||t.multiline!==e.multiline||t.sticky!==e.sticky||t.unicode!==e.unicode)return!1}for(var s=n.length-1;s>=0;){if(n[s]===t)return r[s]===e;s-=1}switch(a){case"Map":return t.size===e.size&&w(t.entries(),e.entries(),n.concat([t]),r.concat([e]));case"Set":return t.size===e.size&&w(t.values(),e.values(),n.concat([t]),r.concat([e]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var l=g(t);if(l.length!==g(e).length)return!1;var f=n.concat([t]),d=r.concat([e]);for(s=l.length-1;s>=0;){var p=l[s];if(!c(p,e)||!m(e[p],t[p],f,d))return!1;s-=1}return!0}var b=o((function(t,e){return m(t,e,[],[])}));var A=r((function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():i(t)?[]:function(t){return"[object String]"===Object.prototype.toString.call(t)}(t)?"":function(t){return"[object Object]"===Object.prototype.toString.call(t)}(t)?{}:f(t)?function(){return arguments}():function(t){var e=Object.prototype.toString.call(t);return"[object Uint8ClampedArray]"===e||"[object Int8Array]"===e||"[object Uint8Array]"===e||"[object Int16Array]"===e||"[object Uint16Array]"===e||"[object Int32Array]"===e||"[object Uint32Array]"===e||"[object Float32Array]"===e||"[object Float64Array]"===e||"[object BigInt64Array]"===e||"[object BigUint64Array]"===e}(t)?t.constructor.from(""):void 0})),O=r((function(t){return null!=t&&b(t,A(t))})),S=o((function(t,e){var n={};for(var r in e)t(e[r],r,e)&&(n[r]=e[r]);return n}));const j=t=>"object"==typeof t||"string"==typeof t?!O(t):O(t),_=t=>!(t=>void 0===t)(t)&&(t=>null!=t)(t)&&j(t);var B="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function x(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function k(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")&&1===Object.keys(t).length?t.default:t}var I={exports:{}};var E={exports:{}};const R=k(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var U;E.exports;function C(){return U||(U=1,E.exports=(t=t||function(t,e){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==B&&B.crypto&&(n=B.crypto),!n)try{n=R}catch(t){}var r=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),i={},a=i.lib={},s=a.Base={extend:function(t){var e=o(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=s.extend({init:function(t,n){t=this.words=t||[],this.sigBytes=n!=e?n:4*t.length},toString:function(t){return(t||l).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i>>2]>>>24-i%4*8&255;e[r+i>>>2]|=a<<24-(r+i)%4*8}else for(var s=0;s>>2]=n[s>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=s.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new c.init(n,e/2)}},f=u.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new c.init(n,e)}},d=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},p=a.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n,r=this._data,o=r.words,i=r.sigBytes,a=this.blockSize,s=i/(4*a),u=(s=e?t.ceil(s):t.max((0|s)-this._minBufferSize,0))*a,l=t.min(4*u,i);if(u){for(var f=0;f>>7)^(h<<14|h>>>18)^h>>>3,g=c[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;c[p]=y+c[p-7]+v+c[p-16]}var w=r&o^r&i^o&i,m=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=d+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&l^~u&f)+s[p]+c[p];d=f,f=l,l=u,u=a+b|0,a=i,i=o,o=r,r=b+(m+w)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+l|0,n[6]=n[6]+f|0,n[7]=n[7]+d|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,o=8*e.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=t.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=o._createHelper(u),e.HmacSHA256=o._createHmacHelper(u)}(Math),P.SHA256)),I.exports)),D=(t={},e={})=>{var n,r;const o={},{email:i,externalId:a,idfa:s,aaid:c}=t;if(_(i)&&(o.email=T(i).toString()),_(a)&&(o.externalId=T(a).toString()),"string"==typeof(l=null===(n=e.os)||void 0===n?void 0:n.name)&&["ios","watchos","ipados","tvos"].includes(null==l?void 0:l.toLowerCase())){var u;const t=s||(null===(u=e.device)||void 0===u?void 0:u.advertisingId);_(t)&&(o.idfa=T(t).toString())}var l;if("android"===(null===(r=e.os)||void 0===r?void 0:r.name)){var f;const t=c||(null===(f=e.device)||void 0===f?void 0:f.advertisingId);_(t)&&(o.aaid=T(t).toString())}return S(_,o)},H=new class{constructor(t,n){this.level=+n||e.ERROR.value,this.scope=t||""}setLogLevel(t){if(t&&"string"==typeof t){const n=t.toUpperCase();this.level=e[n]?e[n].value:this.level}}setScope(t){this.scope=t||this.scope}log(...t){this.logBase(t,e.LOG.value)}info(...t){this.logBase(t,e.INFO.value)}debug(...t){this.logBase(t,e.DEBUG.value)}warn(...t){this.logBase(t,e.WARN.value)}error(...t){this.logBase(t,e.ERROR.value)}logBase(t,n){if(this.level<=n){Object.values(e).find((t=>t.value===n)).method(...this.getLogData(t))}}getLogData(t){if(Array.isArray(t)&&t.length>0){let e="%c RS SDK";this.scope&&(e=`${e} - ${this.scope}`);e=`${e} %c ${t[0].trim()}`;const n=[];return n.push(e),n.push("font-weight: bold; background: black; color: white;"),n.push("font-weight: normal;"),n.push(...t.slice(1)),n}return t}}("Reddit Pixel");return t.RedditPixel=class{constructor(t,e,n){e.logLevel&&H.setLogLevel(e.logLevel),this.analytics=e,this.pixelId=t.advertiserId,this.name="REDDIT_PIXEL",this.eventMappingFromConfig=t.eventMappingFromConfig,({shouldApplyDeviceModeTransformation:this.shouldApplyDeviceModeTransformation,propagateEventsUntransformedOnError:this.propagateEventsUntransformedOnError,destinationId:this.destinationId}=null!=n?n:{})}init(){const t=this.analytics.getUserTraits();var e,n;e=this.pixelId,n=D(t),function(t,e){if(!t.rdt){var n=t.rdt=function(){n.sendEvent?n.sendEvent.apply(n,arguments):n.callQueue.push(arguments)};n.callQueue=[];var r=e.createElement("script");r.src="https://www.redditstatic.com/ads/pixel.js",r.async=!0,r.setAttribute("data-loader","RS_JS_SDK");var o=e.getElementsByTagName("script")[0];o.parentNode.insertBefore(r,o)}}(window,document),Object.keys(n).length?window.rdt("init",e,n):window.rdt("init",e)}isLoaded(){return!(!window.rdt||window.rdt.pixelId!==this.pixelId)}isReady(){return this.isLoaded()}identify(t){var e,n;this.eventMappingFromConfig.some((t=>"SignUp"===t.to))||window.rdt("track","SignUp");const r=D(null===(e=t.message)||void 0===e||null===(e=e.context)||void 0===e?void 0:e.traits,null===(n=t.message)||void 0===n?void 0:n.context);Object.keys(r).length>0&&window.rdt("init",this.pixelId,r)}track(t){const{event:e}=t.message;if(!e)return void H.error("Event name is required");const n=((t,e="from",n="to",r=!0)=>{const o={};return Array.isArray(t)&&t.forEach((t=>{if(!j(t[e]))return;if("string"!=typeof t[e])return;const i=r?t[e].toLowerCase().trim():t[e].trim();o[i]?o[i].includes(t[n])||o[i].push(t[n]):o[i]=[t[n]]})),o})(this.eventMappingFromConfig,"from","to",!1);if(n[e]){const t=function(t,e){return e[t]?e[t]:null}(e,n);t.forEach((t=>{window.rdt("track",t)}))}else switch(e.toLowerCase()){case"product added":window.rdt("track","AddToCart");break;case"product added to wishlist":window.rdt("track","AddToWishlist");break;case"order completed":window.rdt("track","Purchase");break;case"lead":window.rdt("track","Lead");break;case"view content":case"product viewed":case"productlist viewed":window.rdt("track","ViewContent");break;case"search":window.rdt("track","Search");break;default:H.error(`Invalid event ${e}. Track call not supported`)}}page(t){window.rdt("track","PageVisit")}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({}); //# sourceMappingURL=RedditPixel.min.js.map